Repository navigation
fix(parser/less)!: read a mixin path without parens or lookups in a value as text, as less.js does - #231
Merged
leaysgur merged 3 commits intoDec 2, 2026
Conversation
…alue as text, as less.js does
less.js `mixin.call(inValue)` gives up on a mixin path with neither parens
nor lookups, so `@v: .a .b;` is no call: the variable keeps it as text for
`@{v}` to substitute. It was read as a `LessMixinCall`, with the gap between
the names in no node, and oxfmt printed `@v: .a.b;`.
Such a path is now an error in value position, so a variable declaration
takes the existing raw fallback, flagged `value_is_raw`. A normal property
value has no raw fallback: `a { b: .c; }` is now an error, as in lessc.
Closes oxc-project#230
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… owner-backed tightening - Report `UnexpectedLessMixinCall` instead of `ExpectComponentValue` for a mixin path without parens or lookups in a value - AGENTS.md "Acceptance": rejecting a parse the owner itself rejects is a bug fix, the one exception to "changing acceptance is additive" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bind `(value, value_is_raw)` from the `if` / `match` instead of setting a `mut` flag in the raw-fallback arm, as `Declaration` and `PostcssSimpleVarDeclaration` do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging this PR will not alter performanceWarning oxc-project has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.
Comparing Footnotes
|
Member
|
Thank you~. I added small refactor commits. 👌🏻 |
Merged
Dunqing
pushed a commit
to limadog9/oxc
that referenced
this pull request
Dec 2, 2026
…c-project#30663) A Less variable value with no typed reading is less.js `permissiveValue` text, and `@{v}` substitutes those bytes as written. oxfmt re-spaced it, which changes what the substitution compiles to. oxc-css-parser 0.0.25 (oxc-project/oxc-css-parser#231) reads such a value as a raw token run flagged `LessVariableDeclaration::value_is_raw`, instead of a parenless mixin call (which less.js never takes in a value). This PR bumps the parser and prints a `value_is_raw` value verbatim, like a raw `$var` value. The bump has to land with the printer change: on its own, `@p: .a:hover .b;` moves from the at-rule path (printed as written) to the raw fallback and becomes `.a: hover .b`. ### Example Input: ```less @v: .a .b; @p: .a:hover .b; @q: #ns .m:hover; .x @{v} { c: d; } ``` Before output: ```less @v: .a.b; @p: .a:hover .b; @q: #ns .m: hover; .x @{v} { c: d; } ``` After output: ```less @v: .a .b; @p: .a:hover .b; @q: #ns .m:hover; .x @{v} { c: d; } ``` Both were captured with `cargo run -p oxc_formatter_css --example css_formatter`. - `@v`: `.x @{v}` compiled to `.x .a.b` (a compound selector) instead of `.x .a .b`. - `@q`: `#ns .m: hover` is no longer a `:hover` selector. - Prettier prints `@p: .a: hover .b;` and `@q: #ns .m: hover;`, so this is recorded as a divergence. ### Changes - `print/less.rs`: `write_less_variable_declaration` prints a `value_is_raw` value with `write_verbatim_value`, as `postcss_simple_vars.rs` does. - `DIVERGENCES.md`: `postcss-simple-var-raw-verbatim` is merged into `#substituted-raw-verbatim`, which covers both `$var` and Less variable values (same reason, mechanism and output). Its references and the conformance report are renamed. - `AGENTS.md` "Printing raw vs typed": a Less variable value is listed with postcss-simple-vars. - Pin: `tests/fixtures/format/less/variable-raw-verbatim.less`. --- AI usage: written with Claude Code, model Claude Opus 5.5 (`claude-opus-5-5`); the reasoning effort level is not available to the model. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #230
less.js
mixin.call(inValue)gives up on a mixin path that has neither parens nor lookups ("This isn't a valid in-value mixin call"), so@v: .a .b;is no call:value()fails and the declaration falls back topermissiveValue, which keeps.a .bas text for@{v}to substitute. This parser read it as aLessMixinCallwith two callee children, the gap between them in no node, and oxfmt printed@v: .a.b;:.dark @{v}then compiles to.dark .a.binstead of.dark .a .b.LessVariableDeclaration::value_is_raw.parse_less_maybe_mixin_call_or_with_lookups)..ns.m(),.ns .m()and.ns.m[@r]are calls as before, and so is a statement-position.a .b;.@this: () => { ... };read), now flaggedvalue_is_rawasPostcssSimpleVarDeclarationflags its own: a formatter cannot otherwise tell the raw token run from a typed space list, and has to print it as written.@v: .a .b;and@v: .a;were a typedLessMixinCall, now the raw run.@v: .a:hover .b;was anAtRulenamedv(the typed value stopped at:), now a variable declaration with the raw run.a { b: .c; }and.m(.a);are now errors. lessc 4.4.2 rejects both ("Unrecognised input", "expected ')' got '.'"). I read this as a bug fix toward the owner rather than a new line; if these should stay accepted, I can narrow the change to variable declarations.tests/less_ast_shapes.rs(the raw shapes, and the call shapes that stay),tests/error/less/mixin/bare-call-in-value.less.a { b: e(.c); }still parses, lessc rejects it.oxfmt follow-up, which has to land together with the bump to this release: print a
value_is_rawvalue verbatim. With the bump alone,@v: .a:hover .b;moves from the at-rule path (printed as written) to the raw fallback, and oxfmt prints.a: hover .b, as it already does for@v: #ns .m:hover;onmain; no existingoxc_formatter_cssfixture catches it. Checked locally against this branch: of 23 selector-shaped variable values,mainchanges what 9 compile to (.a .b→.a.b,#ns .m:hover→#ns .m: hover,#ns/* c */.b→#ns /* c */ .b), the follow-up changes none, and the existingoxc_formatter_cssfixtures pass unchanged.AI usage: written with Claude Code, model Claude Fable 5.2 (
claude-fable-5-2); the reasoning effort level is not available to the model.🤖 Generated with Claude Code